<template>
    <div class="box2">
        <div class="title">
            <p> 年龄比例</p>
            <img src="../../images/dataScreen-title.png" alt="">
        </div>

        <div class="charts" ref="charts">
        </div>
    </div>
</template>

<script setup lang='ts' name='Age'>
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';
let charts = ref();

onMounted(() => {
    let mycharts = echarts.init(charts.value)
    let option = {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            right: 10,
            top: 50,
            orient: 'vertical',/// 图形组件方向的设置
            textStyle: {
                color: 'white',
                fontSize: 12
            },
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: ['40%', '70%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 10,
                    borderColor: '#fff',
                    borderWidth: 2
                },
                label: {
                    show: false,
                    position: 'center',
                    color: 'white'
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 40,
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: [
                    { value: 1048, name: '新闻' },
                    { value: 735, name: '军事' },
                    { value: 580, name: '娱乐' },
                    { value: 484, name: '编辑' },
                    { value: 300, name: '视频' }
                ]
            }
        ],
        grid: {
            left: 0,
            right: 0,
            top: 0,
            bottom: 0
        }
    };
    mycharts.setOption(option);
})
</script>

<style scoped lang='scss'>
.box2 {
    width: 100%;
    height: 100%;
    background: url('../../images/dataScreen-main-cb.png') no-repeat;
    background-size: 100% 100%;

    .title {
        margin-left: 20px;

        p {
            color: white;
            font-size: 20px;
        }
    }

    .charts {
        height: 260px;
    }
}
</style>